/*
 * =====================================================================================
 *
 *       Filename:  main.cc
 *
 *    Description:
 *
 *        Version:  1.0
 *        Created:  2022年01月19日 11时46分08秒
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  first_name last_name (fl), fl@my-company.com
 *        Company:  my-company
 *
 * =====================================================================================
 */

#include <iostream>
#include <functional>

using std::cout;
using std::endl;
using std::string;

void call_when_even(int x, const std::function < void (int) >& f) {
    if (!(x & 1)) { // x % 2 == 0
        f(x);
    }
}

void output(int x) {
    std::cout << x << " ";
}

int main(void) {
    for (int i = 0; i < 10; ++i) {
        call_when_even(i, output);
    }

    cout << endl;
    return 0;
}
